#pragma once
#include <iostream>
using namespace std;
template <class T>
class CDSLK
{
	struct T_NODE 
	{
		T data;
		T_NODE * next;
	} ;
	T_NODE *ROOT;
	T_NODE  *CUR;
	
public:
	CDSLK(void);
	~CDSLK(void);
	void add(T data);
	void sort();
	void showAll();
};

template<class T>
CDSLK<T>::CDSLK(void)
{
	ROOT=NULL;
}
template<class T>
CDSLK<T>::~CDSLK(void)
{
	
}
template<class T>
void CDSLK<T>::add(T data)
{
	T_NODE *t1 =(T_NODE*)malloc(sizeof(struct T_NODE));
	
	if(ROOT==NULL)
	{	
		ROOT=t1;
		CUR=t1;//=ROOT
		(*t1).data=data;
		(*t1).next=NULL;
	}
	else
	{
		(*CUR).next=t1;
		(*t1).data=data;
		(*t1).next=NULL;
		CUR=t1;
	}
	
	//cout<<ROOT.data;
	
}
template<class T>
void CDSLK<T>::showAll()
{
	T_NODE r=*ROOT;
	cout<<r.data<<"  ";
	while(r.next!=NULL)
	{
		
		r=*r.next;
		cout<< r.data <<"  ";
	}
}